home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Eudora 1.3.1 / source / Bits / ProcessMenuHelp < prev    next >
Encoding:
Text File  |  1993-03-16  |  1.6 KB  |  77 lines  |  [TEXT/????]

  1. perl -x "{0}" {"parameters"} ; exit
  2. #!/usr/local/bin/perl
  3. open(SRC,"<" . $ARGV[0]) || die;
  4. open(HFIL,">" . $ARGV[1]) || die;
  5. open(SFIL,">" . $ARGV[2]) || die;
  6. $str=$ARGV[3];
  7. $gran=40;
  8. $elem=$gran+1;
  9.  
  10. while (<SRC>)
  11. {
  12.   if (/^#/ || /^\W*$/) {next;}
  13.   chop;
  14.   ($cmd,$rest) = split(/\t/,$_,2);
  15.   if ($cmd eq "MENU")
  16.   {
  17.     if ($id != 0) {print HFIL "}};\n";}
  18.     $id = $rest;
  19.     print HFIL "resource 'hmnu' ($rest,purgeable) { HelpMgrVersion,0,0,0,\n";
  20.     $notfirst = 0;
  21.   }
  22.   elsif ($cmd eq "SKIP")
  23.   {
  24.     print HFIL "HMSkipItem {},\n";
  25.     if ($notfirst == 0)
  26.     {
  27.       print HFIL "{\n";
  28.       $notfirst = 1;
  29.     }
  30.   }
  31.   else
  32.   {
  33.     print HFIL "HMStringResItem {\n";
  34.     @strings = split('##',$rest);
  35.     $rep = $strings[0];
  36.     for ($i=0;$i<=$#strings;$i++)
  37.     {
  38.             $toprint = $strings[$i];
  39.             ($rp,$rest) = split(' ',$toprint,2);
  40.             if ($rp eq "REPEAT") {$toprint = $rep . "\\n" . $rest;}
  41.       if ($toprint eq "")
  42.       {
  43.         print HFIL "0,0,\n";
  44.       }
  45.             elsif ($assigned{$toprint} ne "")
  46.             {
  47.                 print HFIL $assigned{$toprint};
  48.             }
  49.       else
  50.       {
  51.                 if ($elem>=$gran)
  52.                 {
  53.                     if ($elem==$gran) {print SFIL '}};' . "\n";}
  54.                     $elem = 0;
  55.                     $str += 200;
  56.                     printf SFIL "resource 'STR#' (%d,purgeable) {{\n",$str;
  57.                 }
  58.                 $assigned{$toprint} = sprintf("%d,%d,\n",$str,++$elem);
  59.                 printf HFIL $assigned{$toprint};
  60.                 print SFIL "\"$toprint\",\n";
  61.       }
  62.     }
  63.     for (;$i<4;$i++)
  64.     {
  65.       print HFIL "0,0,\n";
  66.     }
  67.     print HFIL "},\n";
  68.     if ($notfirst == 0)
  69.     {
  70.       print HFIL "{\n";
  71.       $notfirst = 1;
  72.     }
  73.   }
  74. }
  75.  
  76. if ($elem>0 && $elem<=$gran) {print SFIL '}};' . "\n";}
  77. if ($id != 0) {print HFIL "}};\n";}